-
Notifications
You must be signed in to change notification settings - Fork 0
[LC-118] chore: adding a remix text area story & fix: #7 Custom attribute getting added to inputs unnecessarily #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe pull request includes several changes across multiple files. Key modifications involve the removal of a Slack notification step from the GitHub Actions workflow, updates to the README documentation, the deletion of a changelog file, and the introduction of new features in the Storybook integration for a Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant RemixTextarea
participant FormHandler
participant Validation
participant Feedback
User->>RemixTextarea: Submit form
RemixTextarea->>FormHandler: Handle submission
FormHandler->>Validation: Validate input
Validation-->>FormHandler: Return validation results
FormHandler->>Feedback: Show success/error message
Feedback-->>User: Display feedback
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (7)
packages/components/src/ui/calendar.tsx (1)
45-47: Consider type-safe props spreading for icon componentsWhile the changes improve type safety with
Partial<CustomComponents>, the current props spreading could be more specific.Consider explicitly typing and spreading only the necessary props:
- IconLeft: ({ ...props }) => <ChevronLeft className="h-4 w-4" {...props} />, - IconRight: ({ ...props }) => <ChevronRight className="h-4 w-4" {...props} />, + IconLeft: ({ className, ...props }: React.ComponentProps<'svg'>) => ( + <ChevronLeft className={cn("h-4 w-4", className)} {...props} /> + ), + IconRight: ({ className, ...props }: React.ComponentProps<'svg'>) => ( + <ChevronRight className={cn("h-4 w-4", className)} {...props} /> + ),This approach:
- Explicitly types the props as SVG element props
- Properly handles className merging
- Makes it clear what props are expected
packages/components/src/ui/radio-group.tsx (1)
70-70: Consider adding null-safe error message access.To improve type safety, consider using optional chaining for error message access:
-{fieldState.error && <FormMessage Component={components?.FormMessage}>{fieldState.error.message}</FormMessage>} +{fieldState.error?.message && ( + <FormMessage Component={components?.FormMessage}>{fieldState.error.message}</FormMessage> +)}apps/docs/src/remix/remix-textarea.stories.tsx (5)
12-16: Consider adding a maximum length constraintWhile the minimum length validation is good, consider adding a maximum length constraint to prevent potential abuse and ensure reasonable input sizes.
const formSchema = z.object({ - description: z.string().min(10, 'Description must be at least 10 characters'), + description: z.string() + .min(10, 'Description must be at least 10 characters') + .max(1000, 'Description must not exceed 1000 characters'), });
22-50: Consider showing loading state during form submissionThe component handles form state well, but could benefit from showing a loading indicator during submission.
<fetcher.Form onSubmit={methods.handleSubmit} method="post" action="/"> <div className="space-y-4 w-[400px]"> <RemixTextarea name="description" label="Description" description="Enter a description (minimum 10 characters)" placeholder="Type your description here..." /> - <Button type="submit" className="w-full">Submit</Button> + <Button + type="submit" + className="w-full" + disabled={fetcher.state === 'submitting'} + > + {fetcher.state === 'submitting' ? 'Submitting...' : 'Submit'} + </Button> {fetcher.data?.message && ( <p className="text-green-600 text-sm">{fetcher.data.message}</p> )}
52-76: Enhance type safety for error responsesConsider defining explicit types for error responses to improve maintainability and type safety.
+type ValidationError = { + errors: { + description?: { + type: string; + message: string; + }; + }; + defaultValues: FormData; +}; + +type SuccessResponse = { + message: string; +}; + -async function handleFormSubmission(request: Request) { +async function handleFormSubmission(request: Request): Promise<ValidationError | SuccessResponse> {
78-102: Consider enhancing Storybook documentationThe metadata could be improved with additional documentation parameters.
parameters: { layout: 'centered', docs: { description: { - component: 'A textarea component that integrates with Remix Form and provides validation feedback.', + component: ` + A textarea component that integrates with Remix Form and provides validation feedback. + + ## Features + - Integrates with Remix Form + - Zod validation + - Error handling + - Success feedback + + ## Usage + \`\`\`tsx + <RemixTextarea + name="description" + label="Description" + description="Helper text" + /> + \`\`\` + `, }, }, },
104-135: Enhance test coverage with additional assertionsWhile the test scenarios are comprehensive, consider adding more assertions for better coverage.
// Test validation error await userEvent.clear(textarea as HTMLTextAreaElement); await userEvent.type(textarea as HTMLTextAreaElement, 'short'); + expect(textarea).toHaveValue('short'); await userEvent.click(canvasElement.querySelector('button[type="submit"]') as HTMLButtonElement); expect(canvasElement.querySelector('.form-message')).toHaveTextContent( 'Description must be at least 10 characters' ); + expect(canvasElement.querySelector('button[type="submit"]')).not.toBeDisabled(); // Test server error await userEvent.clear(textarea as HTMLTextAreaElement); await userEvent.type(textarea as HTMLTextAreaElement, INVALID_CONTENT); + expect(textarea).toHaveValue(INVALID_CONTENT); await userEvent.click(canvasElement.querySelector('button[type="submit"]') as HTMLButtonElement); expect(canvasElement.querySelector('.form-message')).toHaveTextContent(CONTENT_ERROR);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (9)
.github/workflows/release.yml(0 hunks)README.md(2 hunks)apps/docs/CHANGELOG.md(0 hunks)apps/docs/src/remix/remix-textarea.stories.tsx(1 hunks)packages/components/src/remix/remix-textarea.tsx(1 hunks)packages/components/src/ui/calendar.tsx(2 hunks)packages/components/src/ui/form.tsx(1 hunks)packages/components/src/ui/radio-group.tsx(1 hunks)packages/components/src/ui/textarea.tsx(1 hunks)
💤 Files with no reviewable changes (2)
- .github/workflows/release.yml
- apps/docs/CHANGELOG.md
✅ Files skipped from review due to trivial changes (2)
- README.md
- packages/components/src/ui/form.tsx
🔇 Additional comments (8)
packages/components/src/ui/calendar.tsx (2)
3-3: LGTM: Type import addition is appropriate
The addition of the CustomComponents type import is correct and follows TypeScript best practices by using type-only imports.
45-47: Verify the impact on existing Calendar implementations
Let's ensure this change doesn't affect existing Calendar usage patterns.
✅ Verification successful
No breaking changes detected in Calendar component usage
The Calendar component is only used internally within the date-picker component, and the changes to the IconLeft and IconRight props are properly typed as Partial<CustomComponents>. The only usage found is in date-picker.tsx where it's used with mode, selected, and onSelect props, which are unaffected by the icon customization changes.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for Calendar component usage to verify compatibility
rg -t tsx -t jsx "Calendar" --glob '!{*.test.*,*.spec.*}' -A 2 -B 2
Length of output: 95
Script:
#!/bin/bash
# Search for Calendar component usage with ripgrep, without file type filtering
rg "Calendar" --glob '!{*.test.*,*.spec.*}' -A 2 -B 2
# Also check for any potential imports of the Calendar component
rg "import.*Calendar" --glob '!{*.test.*,*.spec.*}'
Length of output: 2596
packages/components/src/ui/radio-group.tsx (2)
63-63: LGTM! Improved error handling implementation.
The changes enhance the error handling by:
- Utilizing React Hook Form's
fieldStatefor validation state - Conditionally rendering error messages only when errors exist
Also applies to: 70-70
63-72: Verify form field integration patterns.
Let's ensure consistent implementation across form field components.
✅ Verification successful
Form field integration pattern is consistent and properly implemented
The implementation follows the same pattern used across all form field components in the codebase:
- All form components use the same
render={({ field, fieldState }) => ...}pattern - Error handling is consistent, using
fieldState.errorwithFormMessage - The
FormMessagecomponent is used uniformly with the same component injection pattern
The radio group implementation matches the established patterns seen in text-field, textarea, checkbox, date-picker, and other form components.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for consistent form field implementation patterns across components
# Check for similar form field components and their error handling
ast-grep --pattern 'render={({ field, fieldState }) => {
$$$
{fieldState.error$$$}
$$$
}}'
# Check for FormMessage usage patterns
rg -A 2 "FormMessage.*Component={components\?.FormMessage}"
Length of output: 316
Script:
#!/bin/bash
# Let's try a different approach to verify form field patterns
# Check for form field components with error handling
rg -U "render=\{\(\{.*fieldState.*\}\).*=>" --type ts
# Check FormMessage usage with proper escaping
rg "FormMessage.*Component=" --type ts
# Look for other form field components for comparison
ast-grep --pattern 'const $_ = forwardRef<$_, $_Props>(($_, ref) => {
$$$
return (
<Controller
$$$
/>
)
})'
Length of output: 1924
apps/docs/src/remix/remix-textarea.stories.tsx (2)
1-11: LGTM! Well-organized imports
The imports are well-structured and demonstrate good separation of concerns between UI components, form handling, and validation libraries.
18-20: LGTM! Clear test constants
The constants are well-named and effectively support different test scenarios.
packages/components/src/remix/remix-textarea.tsx (1)
3-5: LGTM!
The import statements and type alias have been appropriately updated to reflect the new components and props.
packages/components/src/ui/textarea.tsx (1)
6-15: Verify that the 'name' attribute is correctly passed to the underlying textarea
By omitting the 'name' attribute from TextareaHTMLAttributes<HTMLTextAreaElement> and redefining it as a required prop in TextareaProps, there's a risk that the name attribute may not be forwarded to the underlying <textarea> element. This could affect form submissions and accessibility.
Please ensure that the name prop is correctly passed down to the <textarea> to maintain expected behavior.
| const components = { | ||
| FormControl: RemixFormControl, | ||
| FormLabel: RemixFormLabel, | ||
| FormDescription: RemixFormDescription, | ||
| FormMessage: RemixFormMessage, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Memoize the components object to prevent unnecessary re-renders
Currently, the components object is recreated on every render, which can lead to unnecessary re-renders if the Textarea component relies on referential equality for optimizations. Consider wrapping it in a useMemo hook to ensure the object reference remains stable across renders.
Apply this diff to memoize the components object:
- const components = {
+ const components = useMemo(() => ({
FormControl: RemixFormControl,
FormLabel: RemixFormLabel,
FormDescription: RemixFormDescription,
FormMessage: RemixFormMessage,
- };
+ }), []);Also, add the import statement at the top of the file:
import { useMemo } from 'react';There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said this wouldn't add much performance enhancement, so I'm leaving as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaruesink, understood. I'll keep this in mind for future reviews.
✏️ Learnings added
Learnt from: jaruesink
PR: lambda-curry/forms#14
File: packages/components/src/remix/remix-textarea.tsx:10-15
Timestamp: 2024-11-26T05:28:15.991Z
Learning: When reviewing components like `RemixTextarea` in `packages/components/src/remix/`, avoid suggesting to memoize the `components` object with `useMemo` if the performance benefit is minimal.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
…hat can get passed into remix form elements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (4)
packages/components/src/remix/remix-textarea.tsx (1)
8-21: Consider adding JSDoc documentationThe component would benefit from JSDoc documentation explaining its purpose, usage, and integration with Remix forms. This would help developers understand how to properly use this wrapper component.
Add documentation like this:
+/** + * A Remix-compatible textarea component that integrates with remix-hook-form. + * Provides form validation and error handling through the Remix form context. + * + * @example + * ```tsx + * <RemixTextarea name="description" placeholder="Enter description..." /> + * ``` + */ export function RemixTextarea(props: RemixTextareaProps) {packages/components/src/remix/remix-switch.tsx (2)
15-23: Consider if memoization is necessary hereThe memoization of the
componentsobject might be unnecessary in this case because:
- The object is static and simple
- React's reconciliation is already efficient with simple object literals
- The memoization itself has a small performance cost
Consider one of these alternatives:
- const components = useMemo( - () => ({ - FormDescription: RemixFormDescription, - FormControl: RemixFormControl, - FormLabel: RemixFormLabel, - FormMessage: RemixFormMessage, - }), - [] - ); + // Option 1: Define it outside the component since it's static + const switchComponents = { + FormDescription: RemixFormDescription, + FormControl: RemixFormControl, + FormLabel: RemixFormLabel, + FormMessage: RemixFormMessage, + }; + // Option 2: Define it directly in the component if you prefer keeping it scoped + const components = { + FormDescription: RemixFormDescription, + FormControl: RemixFormControl, + FormLabel: RemixFormLabel, + FormMessage: RemixFormMessage, + };
1-1: Consider organizing importsThe imports mix React core, third-party libraries, and local imports.
Consider organizing imports into groups:
- import { useMemo, type ComponentPropsWithoutRef } from 'react'; - import { useRemixFormContext } from 'remix-hook-form' - import { Switch } from '../ui/switch' - import { RemixFormControl, RemixFormDescription, RemixFormLabel, RemixFormMessage } from './remix-form'; + // React core + import { type ComponentPropsWithoutRef } from 'react'; + + // Third-party libraries + import { useRemixFormContext } from 'remix-hook-form' + + // Local imports + import { Switch } from '../ui/switch' + import { + RemixFormControl, + RemixFormDescription, + RemixFormLabel, + RemixFormMessage + } from './remix-form';packages/components/src/ui/textarea.tsx (1)
6-15: Add JSDoc documentation for the TextareaProps interfaceThe generic type parameters and props would benefit from documentation to improve developer experience.
Consider adding documentation like this:
+/** + * Props for the Textarea component + * @template TFieldValues - The type of the form values + * @template TName - The type of the field name + */ export interface TextareaProps< TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues> > extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'name'> { + /** The form control from react-hook-form */ control?: Control<TFieldValues>; + /** The name of the field */ name: TName; + /** Optional label text */ label?: string; + /** Optional description text */ description?: string; + /** Optional custom components for form elements */ components?: Partial<FieldComponents>; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (5)
packages/components/src/remix/remix-checkbox.tsx(1 hunks)packages/components/src/remix/remix-switch.tsx(2 hunks)packages/components/src/remix/remix-text-field.tsx(1 hunks)packages/components/src/remix/remix-textarea.tsx(1 hunks)packages/components/src/ui/textarea.tsx(1 hunks)
🔇 Additional comments (8)
packages/components/src/remix/remix-checkbox.tsx (1)
1-1: LGTM!
Clean import of useMemo from React.
packages/components/src/remix/remix-text-field.tsx (2)
1-21: Well-structured component with proper type safety.
The component demonstrates good practices:
- Clean separation of concerns
- Proper type safety using Omit utility
- Correct integration with remix-hook-form
- Consistent with the broader form component architecture
11-19: Consider measuring the performance impact of memoization.
The memoization of form components is consistent with other Remix form components and prevents unnecessary recreations. However, since these are just component references, the performance benefit might be minimal.
Let's check if similar memoization patterns exist in other Remix components:
✅ Verification successful
Memoization pattern is consistent across Remix form components
The useMemo implementation for form components is consistently applied across all Remix form components (TextField, Textarea, Checkbox, and Switch). This pattern is part of a deliberate architectural decision for form component implementations, not an isolated optimization. The consistent usage across the codebase validates this approach.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for similar useMemo patterns in other Remix form components
# Expected: Find similar patterns to confirm consistency
rg -A 5 "useMemo.*FormControl.*FormLabel.*FormDescription.*FormMessage" packages/components/src/remix/
Length of output: 104
Script:
#!/bin/bash
# Let's search for individual useMemo patterns in Remix components
# to get a better understanding of the memoization patterns
# Search for useMemo in remix components
rg "useMemo\(" packages/components/src/remix/ -B 1 -A 3
# Also search for component definitions to understand the context
ast-grep --pattern 'const $_ = useMemo(() => ({
$$$
}), $_)'
Length of output: 4323
packages/components/src/remix/remix-textarea.tsx (2)
1-6: LGTM! Clean imports and type definition
The change from interface to type alias is appropriate for this use case, and the imports are well-organized.
21-21: Verify component usage patterns
Let's verify how this component is being used across the codebase to ensure consistent implementation.
✅ Verification successful
Component usage appears consistent with Remix form patterns
The verification shows that:
- RemixTextarea is used in storybook documentation with proper form integration
- Direct Textarea usages are only found in the base component and the Remix wrapper itself
- No instances of improper Textarea usage that should be using RemixTextarea instead
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for RemixTextarea usage patterns
echo "Searching for RemixTextarea usage patterns..."
rg -A 3 "<RemixTextarea"
# Check if there are any direct Textarea usages that should be using RemixTextarea instead
echo "Checking for potential missed Remix integration opportunities..."
rg -A 3 "<Textarea" | grep -v "RemixTextarea"
Length of output: 1282
packages/components/src/ui/textarea.tsx (3)
23-39: Well-structured form field implementation with proper error handling
The component now properly handles form validation errors and displays them using FormMessage, while maintaining a clean structure with label, description, and error message placement.
46-46: LGTM: Proper display name setup
The display name is correctly set, which helps with debugging in React DevTools.
25-38: Verify consistent component customization pattern
The component uses a flexible customization pattern with the components prop. Let's verify this pattern is used consistently across other form components.
✅ Verification successful
Component customization pattern is consistently implemented
The search results confirm that the component customization pattern using the components prop is consistently implemented across all form-related components in the codebase:
- FormLabel customization is used in 7 components
- FormControl customization is used in 7 components
- FormDescription customization is used in 8 components
- FormMessage customization is used in 7 components
All form components follow the same pattern of allowing customization through the components prop with optional chaining, maintaining a consistent API across the form component library.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for similar component customization patterns in form components
echo "Searching for FormLabel component customization..."
rg "FormLabel Component={components\?.FormLabel}" --type tsx
echo "Searching for FormControl component customization..."
rg "FormControl Component={components\?.FormControl}" --type tsx
echo "Searching for FormDescription component customization..."
rg "FormDescription Component={components\?.FormDescription}" --type tsx
echo "Searching for FormMessage component customization..."
rg "FormMessage Component={components\?.FormMessage}" --type tsx
Length of output: 1357
Script:
#!/bin/bash
# Search for similar component customization patterns in form components with escaped special characters
echo "Searching for FormLabel component customization..."
rg "FormLabel Component=\{components\?\." --type tsx
echo "Searching for FormControl component customization..."
rg "FormControl Component=\{components\?\." --type tsx
echo "Searching for FormDescription component customization..."
rg "FormDescription Component=\{components\?\." --type tsx
echo "Searching for FormMessage component customization..."
rg "FormMessage Component=\{components\?\." --type tsx
Length of output: 805
Script:
#!/bin/bash
# Search for similar component customization patterns in form components
echo "Searching for FormLabel component customization..."
rg "FormLabel Component=\{components\?\."
echo "Searching for FormControl component customization..."
rg "FormControl Component=\{components\?\."
echo "Searching for FormDescription component customization..."
rg "FormDescription Component=\{components\?\."
echo "Searching for FormMessage component customization..."
rg "FormMessage Component=\{components\?\."
# Also search for files that might contain form components
echo -e "\nSearching for form-related files..."
fd -e tsx -e ts "form" -t f
Length of output: 4867
| const components = useMemo( | ||
| () => ({ | ||
| FormDescription: RemixFormDescription, | ||
| FormControl: RemixFormControl, | ||
| FormLabel: RemixFormLabel, | ||
| FormMessage: RemixFormMessage, | ||
| }), | ||
| [] | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Consider removing unnecessary memoization across all Remix form components
The pattern of memoizing static component references is consistently used across multiple Remix form components:
- packages/components/src/remix/remix-checkbox.tsx
- packages/components/src/remix/remix-switch.tsx
- packages/components/src/remix/remix-textarea.tsx
- packages/components/src/remix/remix-text-field.tsx
All these components use identical memoization for static component references, which adds unnecessary overhead without providing performance benefits. Consider removing useMemo and using direct object assignment in all these files.
🔗 Analysis chain
Consider removing unnecessary memoization
While memoization is generally good for performance, in this specific case, it might be unnecessary overhead since:
- The components object only contains static component references that never change
- The overhead of creating this simple object is minimal
- The useMemo hook itself adds a small memory overhead
Consider simplifying to:
- const components = useMemo(
- () => ({
- FormDescription: RemixFormDescription,
- FormControl: RemixFormControl,
- FormLabel: RemixFormLabel,
- FormMessage: RemixFormMessage,
- }),
- []
- );
+ const components = {
+ FormDescription: RemixFormDescription,
+ FormControl: RemixFormControl,
+ FormLabel: RemixFormLabel,
+ FormMessage: RemixFormMessage,
+ };Let's verify if this pattern is consistently used across other similar components:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if other Remix components use similar memoization pattern
# This will help understand if this is part of a broader optimization strategy
# Search for similar useMemo patterns in Remix components
ast-grep --pattern 'const components = useMemo(() => ({$$$}), []);' packages/components/src/remix/
Length of output: 2832
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yikes, this is opposite advice of what you gave earlier. I'll remove these, because I don't like the useMemo approach if not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaruesink, I apologize for the conflicting advice earlier. You're correct; if the useMemo approach isn't necessary, removing it is the right decision.
✏️ Learnings added
Learnt from: jaruesink
PR: lambda-curry/forms#14
File: packages/components/src/remix/remix-checkbox.tsx:11-19
Timestamp: 2024-11-26T05:25:46.556Z
Learning: Ensure consistency when advising on the use of `useMemo` for static component references in Remix form components, avoiding unnecessary memoization where it doesn't provide performance benefits.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
| {...field} | ||
| {...props} | ||
| ref={field.ref} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider handling multiple refs properly
The current implementation might override external refs when spreading props before the field.ref assignment.
Consider using a ref merging utility to handle both external refs and form refs:
+import { useMergeRefs } from '@hooks/use-merge-refs';
// Inside the render function
+const mergedRef = useMergeRefs([ref, field.ref]);
<textarea
className={cn(
'flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
className,
)}
{...field}
{...props}
- ref={field.ref}
+ ref={mergedRef}
/>Committable suggestion skipped: line range outside the PR's diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay to have the parent ref go to the parent field item and keep this ref the field.ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaruesink, understood. We'll keep the current implementation as is.
✏️ Learnings added
Learnt from: jaruesink
PR: lambda-curry/forms#14
File: packages/components/src/ui/textarea.tsx:32-34
Timestamp: 2024-11-26T05:29:38.992Z
Learning: In the `Textarea` component (`packages/components/src/ui/textarea.tsx`), it's acceptable to assign `field.ref` directly to the `ref` of the textarea element without merging it with external refs.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (12)
packages/components/src/ui/text-field.tsx (1)
25-46: Well-structured component implementationThe component demonstrates good architectural practices:
- Proper integration with react-hook-form
- Flexible component composition through the components prop
- Comprehensive error handling with fieldState
- Type-safe implementation with generics
Consider adding unit tests to verify the behavior with both controlled and uncontrolled usage patterns.
packages/components/src/ui/textarea.tsx (2)
6-15: Consider adding JSDoc documentationThe interface is well-typed and provides excellent type safety for form integration. Consider adding JSDoc documentation to explain the generic parameters and props for better developer experience.
Example documentation:
/** * Props for the Textarea component. * @template TFieldValues - The type of the form values * @template TName - The type of the field name */ export interface TextareaProps< TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues> > { /** The form control from react-hook-form */ control?: Control<TFieldValues>; /** The name of the field in the form */ name: TName; /** Optional label text */ label?: string; /** Optional description text */ description?: string; /** Optional component overrides */ components?: Partial<FieldComponents>; }
32-34: Consider props spreading orderThe current order of spreading props might allow overriding of important field properties. Consider reversing the order to ensure field properties take precedence.
-{...field} -{...props} -ref={field.ref} +{...props} +{...field} +ref={useMergeRefs([ref, field.ref])}packages/components/src/ui/switch.tsx (1)
26-26: Review ref handling changesThe ref handling has been restructured:
- The main ref is now attached to the FormItem wrapper
- The Switch primitive now uses field.ref from react-hook-form
This change improves form integration but introduces a potential gotcha:
- The ref now points to the wrapper div instead of the switch input
- This might affect accessibility tools or custom logic expecting the ref to point to the input element
Consider documenting this behavior change in the component's documentation or adding a second ref prop specifically for the switch input if needed.
Also applies to: 33-33
packages/components/src/ui/date-picker.tsx (2)
40-40: Consider ref handling implicationsMoving the ref to FormItem wraps the entire form control group, which is good for form layouts but might affect direct DOM manipulation needs. Ensure this aligns with your use cases.
Consider documenting this ref behavior in component documentation to help consumers understand what element they're referencing.
Line range hint
50-57: Improved form integration with field.refThe Button now correctly uses field.ref from react-hook-form, which is the recommended approach for form library integration. This ensures proper form state management and validation handling.
Consider adding aria-invalid and aria-describedby attributes for better accessibility:
<Button ref={field.ref} variant="outline" + aria-invalid={!!fieldState.error} + aria-describedby={fieldState.error ? `${name}-error` : undefined} className={cn( 'w-[280px] justify-start text-left font-normal', !field.value && 'text-muted-foreground', buttonClassName, )} >packages/components/src/remix/remix-form.tsx (2)
43-57: Consider enhancing error message handlingThe implementation looks good with proper ref forwarding and accessibility attributes. However, consider adding error message logging or telemetry for better debugging in production.
export const RemixFormControl = forwardRef<HTMLDivElement, ComponentPropsWithoutRef<typeof FormControl>>( (props, ref) => { const { error, formItemId, formDescriptionId, formMessageId } = useRemixFormField(); + // Consider adding error logging/telemetry here + if (error) { + console.error('Form control error:', { fieldId: formItemId, error }); + } return ( <FormControl ref={ref}
68-73: Enhance error handling and accessibilityWhile the implementation is good, consider these improvements:
- Add null checks for error message
- Include aria-invalid attribute for better accessibility
export const RemixFormMessage = forwardRef<HTMLParagraphElement, ComponentPropsWithoutRef<typeof FormMessage>>( (props, ref) => { const { error, formMessageId } = useRemixFormField(); - return <FormMessage ref={ref} formMessageId={formMessageId} error={error?.message} {...props} />; + const errorMessage = error?.message ?? null; + return ( + <FormMessage + ref={ref} + formMessageId={formMessageId} + error={errorMessage} + aria-invalid={!!errorMessage} + {...props} + /> + ); }, );packages/components/src/ui/checkbox.tsx (1)
35-38: LGTM: Improved form integrationThe ref handling changes correctly integrate with react-hook-form by:
- Using
field.reffor form state management- Forwarding the outer ref to FormItem for layout/accessibility
Consider adding a comment explaining this ref handling strategy:
<FormItem className={cn('flex flex-row items-start space-x-3 space-y-0', className)} ref={ref}> <FormControl Component={components?.FormControl}> <CheckboxPrimitive.Root + // Using field.ref for react-hook-form integration ref={field.ref}packages/components/src/ui/radio-group.tsx (1)
70-70: Consider enhancing error message accessibilityThe conditional error message rendering is a good improvement. However, consider adding an aria-live region to ensure screen readers announce when error messages appear.
- {fieldState.error && <FormMessage Component={components?.FormMessage}>{fieldState.error.message}</FormMessage>} + {fieldState.error && ( + <div aria-live="polite"> + <FormMessage Component={components?.FormMessage}>{fieldState.error.message}</FormMessage> + </div> + )}packages/components/src/ui/input-otp.tsx (2)
105-105: Well-structured ref handling for form integrationGood use of
field.reffor form control integration while maintaining separation of concerns between form control refs and component container refs. This architecture allows for better form state management through react-hook-form while keeping the component container independently referenceable.
Line range hint
114-124: Consider making slot rendering more dynamicThe current implementation handles 8 slots specifically, but could be more flexible by dynamically rendering slots based on maxLength.
Consider refactoring to use Array.from for dynamic slot rendering:
- <InputOTPGroup> - <InputOTPSlot index={0} /> - <InputOTPSlot index={1} /> - <InputOTPSlot index={2} /> - {isEightSlots && <InputOTPSlot index={3} />} - </InputOTPGroup> - <InputOTPSeparator /> - <InputOTPGroup> - <InputOTPSlot index={isEightSlots ? 4 : 3} /> - <InputOTPSlot index={isEightSlots ? 5 : 4} /> - <InputOTPSlot index={isEightSlots ? 6 : 5} /> - {isEightSlots && <InputOTPSlot index={7} />} - </InputOTPGroup> + {Array.from({ length: Math.ceil(maxLength/4) }).map((_, groupIndex) => ( + <> + {groupIndex > 0 && <InputOTPSeparator />} + <InputOTPGroup> + {Array.from({ length: Math.min(4, maxLength - groupIndex * 4) }).map((_, slotIndex) => ( + <InputOTPSlot key={groupIndex * 4 + slotIndex} index={groupIndex * 4 + slotIndex} /> + ))} + </InputOTPGroup> + </> + ))}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (11)
.vscode/settings.json(1 hunks)packages/components/src/remix/remix-form.tsx(2 hunks)packages/components/src/ui/checkbox.tsx(2 hunks)packages/components/src/ui/date-picker.tsx(2 hunks)packages/components/src/ui/form.tsx(4 hunks)packages/components/src/ui/input-otp.tsx(2 hunks)packages/components/src/ui/input.tsx(1 hunks)packages/components/src/ui/radio-group.tsx(1 hunks)packages/components/src/ui/switch.tsx(2 hunks)packages/components/src/ui/text-field.tsx(2 hunks)packages/components/src/ui/textarea.tsx(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- packages/components/src/ui/input.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/components/src/ui/form.tsx
🔇 Additional comments (19)
.vscode/settings.json (3)
2-2: LGTM: Spell checker words are appropriate
The spell checker words list includes relevant technical terms and tool names used in the project.
10-13: LGTM: Safe code actions configuration
The code actions are properly configured with "explicit" mode, requiring user confirmation before applying changes. This is a safe default that prevents unwanted automatic modifications while still providing the convenience of Biome's formatting and import organization features.
3-9: Verify Biome formatter configuration and potential conflicts
The configuration sets Biome as the default formatter. Please ensure:
- Biome is installed as a VS Code extension
- There are no conflicts with other formatters (e.g., Prettier) or ESLint configurations
✅ Verification successful
Let me gather more information to check for any potential conflicts in the configuration files.
Biome formatter configuration is correctly set up without conflicts
The configuration is valid as:
- Only Biome (@biomejs/biome v1.9.1) is installed as a formatting dependency
- No conflicting Prettier or ESLint configurations exist
- A biome.json configuration file is present
- No other VS Code formatter settings exist for JavaScript/TypeScript files
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for potential formatter conflicts
# Check for Prettier config
echo "Checking for Prettier config files..."
fd -t f "^\.prettier" -t f "prettier\.config\."
# Check for ESLint config
echo "Checking for ESLint config files..."
fd -t f "^\.eslint" -t f "eslint\.config\."
# Check package.json for formatting-related dependencies
echo "Checking package.json for formatter dependencies..."
if [ -f "package.json" ]; then
jq '.dependencies + .devDependencies | with_entries(select(.key | test("prettier|eslint|biome")))' package.json
fi
Length of output: 757
Script:
#!/bin/bash
# Check for any other formatter or linter configurations
echo "Checking for any config files..."
fd -e json -e js -e cjs -e yaml -e yml | grep -iE '(prettier|eslint|biome|format)'
# Check if there are any other VS Code settings that might conflict
echo "Checking VS Code settings..."
if [ -f ".vscode/settings.json" ]; then
jq '.[".js"]?, .[".jsx"]?, .[".ts"]?, .[".tsx"]?, .["javascript"]?, .["javascriptreact"]?' .vscode/settings.json
fi
# Check for biome configuration
echo "Checking for Biome config..."
fd "biome.json"
Length of output: 511
packages/components/src/ui/text-field.tsx (1)
25-25: Verify the impact of ref type change
The component's ref type has been changed from HTMLInputElement to HTMLDivElement, and the ref handling has been restructured:
- The main ref now points to the FormItem wrapper
- The input element uses
field.ref
This change might affect existing code that expects an input ref.
Also applies to: 35-35, 38-38
✅ Verification successful
No impact found from TextField ref type change
Based on the codebase analysis, there are no direct usages of TextField's ref found in the codebase. The component is primarily used through the RemixTextField wrapper, which doesn't utilize the ref prop. The change from HTMLInputElement to HTMLDivElement appears to be safe to implement.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for TextField ref usage in the codebase
rg -A 3 "TextField.*ref" --type tsx --type ts
Length of output: 75
Script:
#!/bin/bash
# Search for TextField ref usage in the codebase with ripgrep
rg -A 3 "TextField.*ref" --type typescript
Length of output: 79
Script:
#!/bin/bash
# Search for TextField component usage with useRef
rg -A 3 "useRef.*TextField" --type typescript
Length of output: 82
Script:
#!/bin/bash
# Find all TypeScript/TSX files that import TextField
rg "import.*TextField.*from.*components" --type typescript
Length of output: 95
Script:
#!/bin/bash
# Find all TypeScript/TSX files in the repository
fd "\.(tsx|ts)$" -x rg -l "TextField"
Length of output: 185
Script:
#!/bin/bash
# Check content of files that use TextField for ref usage
cat "./apps/docs/src/remix/remix-text-field.stories.tsx" "./packages/components/src/remix/remix-text-field.tsx"
Length of output: 5773
Script:
#!/bin/bash
# Search for useRef or ref patterns in files containing TextField
rg "useRef|ref=" "./apps/docs/src/remix/remix-text-field.stories.tsx" "./packages/components/src/remix/remix-text-field.tsx"
Length of output: 122
Script:
#!/bin/bash
# Search for TextField usage in the entire codebase with grep
rg -A 5 "<TextField" .
# Also search for any direct ref usage with TextField
rg -A 5 "TextField.*ref|ref.*TextField" .
Length of output: 779
packages/components/src/ui/textarea.tsx (2)
1-4: LGTM: Imports are well-organized and necessary
The imports are logically structured and all are being utilized in the implementation.
46-46: LGTM: Display name properly set
Setting the display name is good practice for debugging purposes.
packages/components/src/ui/switch.tsx (3)
Line range hint 33-40: Validate form control integration
The Switch primitive's integration with react-hook-form looks correct:
- Uses field.ref for DOM reference
- Properly binds checked state to field.value
- Handles changes via field.onChange
Line range hint 41-46: LGTM: Styling implementation
The styling implementation using cn utility and Radix's data attributes is well-structured and follows best practices for handling component states.
20-22: Verify the ref type change impact
The component's ref type has been changed from ElementRef<typeof SwitchPrimitives.Root> to HTMLDivElement. While this aligns with moving the ref to the FormItem wrapper, we should verify this doesn't break existing ref usage.
✅ Verification successful
Ref type change is safe to proceed
The search results show that the Switch component is not being used with refs in any consumer code. The only ref usage is internal within the component itself, where it's properly handled by passing field.ref to the SwitchPrimitives.Root. The change from ElementRef<typeof SwitchPrimitives.Root> to HTMLDivElement is safe as it matches the new structure where the ref is forwarded to the FormItem wrapper (which is a div).
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for Switch component usage with ref
ast-grep --pattern 'const $_ = useRef<$_>();
$$$
<Switch ref={$_} $$$'
# Also search for direct ref assignments
rg -A 2 'ref={.*}.*<Switch'
Length of output: 207
Script:
#!/bin/bash
# Search for Switch component usage with ref, fixing the regex
rg -U '<Switch.*ref=' -A 2
# Search for useRef declarations followed by Switch usage within a reasonable context
rg -U 'useRef.*\n.*(?s:.)*?<Switch' --multiline
# Search for any Switch component usage to understand the context
rg -U '<Switch' -B 2 -A 2
Length of output: 1271
packages/components/src/ui/date-picker.tsx (1)
33-33: Verify accessibility implications of ref type change
Changing the ref from HTMLButtonElement to HTMLDivElement might affect focus management and keyboard navigation, as the primary interactive element (Button) no longer receives the forwarded ref.
✅ Verification successful
Ref forwarding implementation is correct and maintains accessibility
The implementation correctly handles focus management and keyboard navigation:
- The
Buttoncomponent receives the form field's ref (field.ref) from react-hook-form, ensuring proper form control functionality - The outer
FormItemreceives the forwarded ref, which is appropriate as it's the container component - The button remains the primary interactive element with its own ref handling through react-hook-form's field control
The ref type change from HTMLButtonElement to HTMLDivElement is justified because:
- The DatePicker's root component is now FormItem (a div-based container)
- The Button component maintains its own ref through react-hook-form's field.ref
- This pattern follows react-hook-form's best practices for form control integration
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for similar date picker implementations to verify ref handling patterns
ast-grep --pattern 'forwardRef<HTMLDivElement, $props>($$$)'
Length of output: 62
Script:
#!/bin/bash
# Let's search for the complete DatePicker implementation to understand the ref usage
ast-grep --pattern 'export const DatePicker = forwardRef<$type, $props>($$$)'
# Also search for FormItem usage within DatePicker to understand ref forwarding
rg "FormItem" "packages/components/src/ui/date-picker.tsx" -A 5 -B 5
# Search for Button usage to verify ref handling
rg "Button" "packages/components/src/ui/date-picker.tsx" -A 5 -B 5
Length of output: 2421
packages/components/src/remix/remix-form.tsx (2)
1-5: LGTM! Well-organized imports
The imports are properly structured with explicit type imports, enhancing type safety and code clarity.
60-65: LGTM! Clean implementation
The RemixFormDescription component is well-implemented with proper ref forwarding and type safety.
packages/components/src/ui/checkbox.tsx (2)
1-1: LGTM: Correct import for forwardRef
The removal of the type keyword from the forwardRef import is correct since forwardRef is needed at runtime.
29-29: Verify ref type change implications
The ref type change from ElementRef<typeof CheckboxPrimitive.Root> to HTMLDivElement means consumers can no longer access checkbox-specific methods through refs. Ensure this aligns with the intended usage pattern.
✅ Verification successful
Ref type change is safe to proceed
The ref type change from ElementRef<typeof CheckboxPrimitive.Root> to HTMLDivElement is justified and safe. The search results show that:
- There are no external usages of Checkbox refs in the codebase
- The only ref usages are internal to the component itself:
- One for forwarding to FormItem (which is a div, matching the new type)
- One for form field integration
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any direct ref usage of this component that might be affected
rg -l "useRef.*<.*Checkbox"
rg "ref=.*{.*}" --type tsx -A 2 -B 2 | grep -B 2 -A 2 "Checkbox"
Length of output: 194
Script:
#!/bin/bash
# Search for any direct ref usage of this component that might be affected
rg "useRef.*Checkbox"
# Search for ref prop usage with Checkbox component
rg "ref.*=.*" --type tsx -A 2 -B 2 | rg -B 2 -A 2 "<Checkbox"
# Look for Checkbox component usage patterns
rg "<Checkbox" --type tsx -A 2 -B 2
# Check if there are any stories or tests using refs with Checkbox
fd "checkbox" -e stories.tsx -e test.tsx -e spec.tsx --exec rg "useRef|ref=" {}
Length of output: 263
Script:
#!/bin/bash
# Search for any direct ref usage of this component that might be affected
rg "useRef.*Checkbox"
# Search for ref prop usage with Checkbox component
rg -t ts -t tsx "ref.*=.*" -A 2 -B 2 | rg -B 2 -A 2 "<Checkbox"
# Look for Checkbox component usage patterns
rg -t ts -t tsx "<Checkbox" -A 2 -B 2
# Check if there are any stories or tests using refs with Checkbox
fd -e ts -e tsx -g "*checkbox*" | xargs rg "useRef|ref="
Length of output: 458
packages/components/src/ui/radio-group.tsx (3)
57-57: LGTM: Improved type safety with more specific ref type
The change from ElementRef<typeof RadioGroup> to HTMLDivElement better reflects the actual DOM structure since the ref is applied to the wrapping FormItem div element.
63-63: LGTM: Enhanced error handling with fieldState
Adding fieldState to the render function enables proper form validation state handling, following react-hook-form best practices.
67-67: LGTM: Proper form integration with field.ref
Using field.ref instead of the direct ref ensures proper integration with react-hook-form's field registration system.
packages/components/src/ui/input-otp.tsx (2)
97-97: LGTM: Proper ref handling for form container
The ref is correctly passed to FormItem, following form component best practices by allowing the entire form field container to be referenced.
85-85: Verify consistency of ref type changes across form components
The change from ElementRef<typeof OTPInput> to HTMLDivElement for the forwarded ref is a breaking change that could affect existing code relying on the OTPInput ref.
Let's verify if this change is consistent with other form field components:
✅ Verification successful
The previous pattern might have been too specific. Let's broaden our search to understand the ref type patterns across form components and identify relevant form field components for analysis.
Let's examine the ref types in other form components and their FormItem usage to understand if this is a consistent pattern.
Change to HTMLDivElement ref type is consistent with form component patterns
The change from ElementRef<typeof OTPInput> to HTMLDivElement for the forwarded ref is consistent with the form component patterns in the codebase:
- TextField uses
forwardRef<HTMLDivElement, TextFieldProps> - FormItem uses
forwardRef<HTMLDivElement, FormItemProps> - All form field components (TextField, Checkbox, RadioGroup) consistently:
- Use FormItem as their outer wrapper
- Forward their ref to FormItem
- Use HTMLDivElement as their ref type
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for similar form field components to verify ref type consistency
ast-grep --pattern 'export const $FIELD = forwardRef<HTMLDivElement, $Props>'
Length of output: 79
Script:
#!/bin/bash
# Let's try a broader pattern to find form field components using forwardRef
ast-grep --pattern 'export const $_ = forwardRef<$TYPE, $_>('
# Also search for specific form field components
rg -l "FormField|InputField|TextField|SelectField|CheckboxField|RadioField" --type ts
Length of output: 671
Script:
#!/bin/bash
# Let's examine the ref types in these specific form-related components
echo "=== text-field.tsx ==="
cat packages/components/src/ui/text-field.tsx | grep -A 1 "export const.*forwardRef"
echo -e "\n=== form.tsx ==="
cat packages/components/src/ui/form.tsx | grep -A 1 "export const.*forwardRef"
echo -e "\n=== checkbox.tsx ==="
cat packages/components/src/ui/checkbox.tsx | grep -A 1 "export const.*forwardRef"
echo -e "\n=== radio-group.tsx ==="
cat packages/components/src/ui/radio-group.tsx | grep -A 1 "export const.*forwardRef"
# Also check FormItem usage in these components
echo -e "\n=== FormItem usage ==="
rg "FormItem" packages/components/src/ui/{text-field,form,checkbox,radio-group}.tsx
Length of output: 3265
| console.log('field', field); | ||
| console.log('props', props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove console.log statements
These debugging statements should be removed before merging to production.
- console.log('field', field);
- console.log('props', props);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| console.log('field', field); | |
| console.log('props', props); |
| export const Textarea = forwardRef<HTMLDivElement, TextareaProps>( | ||
| ({ control, name, label, description, className, components, ...props }, ref) => { | ||
| return ( | ||
| <FormField | ||
| control={control} | ||
| name={name} | ||
| render={({ field, fieldState }) => ( | ||
| <FormItem className={className} ref={ref}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review ref forwarding implementation
The current ref implementation has two potential issues:
- The ref is forwarded to FormItem instead of the textarea element
- There might be conflicts between the forwarded ref and field.ref
Consider this implementation:
-export const Textarea = forwardRef<HTMLDivElement, TextareaProps>(
+export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
({ control, name, label, description, className, components, ...props }, ref) => {
return (
<FormField
control={control}
name={name}
render={({ field, fieldState }) => (
- <FormItem className={className} ref={ref}>
+ <FormItem className={className}>Committable suggestion skipped: line range outside the PR's diff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the textarea gets field.ref so we should be good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaruesink, understood. Since the textarea element receives field.ref, and the ref forwarding is handled appropriately, we should be good. Thanks for the clarification.
✏️ Learnings added
Learnt from: jaruesink
PR: lambda-curry/forms#14
File: packages/components/src/ui/textarea.tsx:17-24
Timestamp: 2024-11-26T05:28:58.646Z
Learning: In `packages/components/src/ui/textarea.tsx`, the `Textarea` component forwards its ref to `FormItem`, and the textarea element receives `field.ref`, so the ref forwarding works correctly.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
.changeset/heavy-dragons-drop.md (1)
6-6: Enhance the change descriptionThe description could be more comprehensive and properly formatted:
-Added remix textarea story and fixes a react error +Added Remix textarea story and fixed a React error. Also resolved issue #7 regarding unnecessary custom attributes on inputs.🧰 Tools
🪛 LanguageTool
[grammar] ~6-~6: “React” is a proper noun and needs to be capitalized.
Context: ... Added remix textarea story and fixes a react error(A_GOOGLE)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
.changeset/heavy-dragons-drop.md(1 hunks)
🧰 Additional context used
🪛 LanguageTool
.changeset/heavy-dragons-drop.md
[grammar] ~6-~6: “React” is a proper noun and needs to be capitalized.
Context: ... Added remix textarea story and fixes a react error
(A_GOOGLE)
🔇 Additional comments (1)
.changeset/heavy-dragons-drop.md (1)
1-4: LGTM: Version bumps are appropriate
The minor version increments for both packages are appropriate given the new feature (Remix textarea story) and bug fixes.
Bfunk54
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Thank you!
Fixes: #7
Summary by CodeRabbit
New Features
RemixTextareacomponent with validation and submission handling in Storybook.Textareacomponent for improved form management and error handling withreact-hook-form.Calendarcomponent to support custom components and improved prop handling.DatePickerandInputOTPFieldcomponents for better integration with form handling.RemixTextareacomponent to demonstrate usage.Bug Fixes
Chores
CHANGELOG.mdfile for@lambdacurry/forms-docs.